package app

import (
	"gitee.com/dayu1985/framework/context"
	"github.com/giter/go.rice"
)

var cfg *context.Configuration

func MustBool(section, key string, defaultVal ...bool) bool {
	if cfg == nil {
		panic("配置文件未初始化...")
	}
	return cfg.INI.MustBool(section, key, defaultVal...)
}
func MustValue(section, key string, defaultVal ...string) string {
	if cfg == nil {
		panic("配置文件未初始化...")
	}
	return cfg.INI.MustValue(section, key, defaultVal...)
}

func MustInt(section, key string, defaultVal ...int) (int, error) {
	if cfg == nil {
		panic("配置文件未初始化...")
	}
	return cfg.INI.Int(section, key)
}

func Init(cbox *rice.Box) *context.Configuration {
	cfg = context.InitConfig(cbox)
	return cfg
}
func GetConfig() *context.Configuration {
	return cfg
}
